<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <f:loadBundle basename="com.Bundle" var="msg"/>
    <h:body>
        <f:view>
            <h:form>
                <h1><h:outputText value="#{msg.customer_datatable_header}"/></h1>
                <h:dataTable value="#{customerBean.customers}" var="item"
                             rowClasses="firstRow,secondRow"
                             columnClasses=""
                             headerClass="tableHeader"
                             style="border-collapse:collapse;vertical-align:middle; text-decoration:none;margin-left:15px;">
                    >
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.customer_datatable_name}"/>
                        </f:facet>
                        <h:commandLink action="#{customerBean.edit(item.id)}" ><h:outputText value="#{item.name}"/></h:commandLink>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.customer_datatable_email}"/>
                        </f:facet>
                        <h:outputText value="#{item.email}"/>
                    </h:column>
                    <f:facet name="footer">
                        <h:commandButton action="#{customerBean.createNewCustomer}" value="#{msg.new_button}"/>
                    </f:facet>
                </h:dataTable>
                <h:panelGroup style="visibility: #{customerBean.editMode ? 'visible':'hidden'};">
                    <h:form>
                        <h:inputHidden id="id" value="#{customerBean.customer.id}"/>
                        <h1><h:outputText value="#{msg.edit_header}"/></h1>
                        <h:panelGrid columns="2">
                            <h:outputLabel value="#{msg.customer_datatable_name}:" for="name" />
                            <h:inputText id="name" value="#{customerBean.customer.name}" title="Name" />
                            <h:outputLabel value="#{msg.customer_datatable_email}:" for="email" />
                            <h:inputText id="email" value="#{customerBean.customer.email}" title="Email" />
                        </h:panelGrid>
                        <h:commandButton value="#{msg.save_button}" action="#{customerBean.save}"/>
                    </h:form>
                </h:panelGroup>
            </h:form>
        </f:view>
    </h:body>
</html>
